package com.khyr.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author 宋一恒
 * @version 1.0
 */
@Configuration
public class PasswordEncoderConfig {

    /**
     * 配置密码编码器Bean
     * 使用BCrypt强哈希算法，版本2a，强度因子默认为10
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();

        // 若要自定义强度因子（4-31），可改为：
        // return new BCryptPasswordEncoder(12);
    }
}
